package com.twu.biblioteca;


public class Library {

    private Register register;
    private Librarian librarian;
    private Customer customer;

    public Library(Librarian librarian)
    {
        register =librarian.register;
        this.librarian =librarian;

    }


    public boolean loginUser(String userId, String password)
    {
        customer= register.checkUser(userId,password);
        if(customer!=null)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public String getUserDetails()
    {
        return customer.getDetails();
    }

    public String returnBook(String isbn) {
        if(searchAllBook(isbn))
        {
            if(librarian.returnBook(customer, isbn))
            {
                return "Thank you for returning the book.";
            }

        }
        return "That is not a valid book to return.";
    }

    public boolean searchAllBook(String isbn) {
        return librarian.searchAllBook( isbn);
    }

    public String checkOutBook(String isbn) {
        if(searchBook(isbn))
        {
            Book book = librarian.checkOutBook(customer, isbn);
            if(book !=null)
            {
                return "Thank you! Enjoy the book";
            }

        }
        return "That book is not available.";
    }

    public boolean searchBook(String isbn) {
        return librarian.searchBook(isbn);
    }

    public String getBookList() {
        return librarian.getBooks();
    }


    public String returnMovie(String name) {
        if(searchAllMovie(name))
        {
            if(librarian.returnMovie(customer, name))
            {
                return "Thank you for returning the book.";
            }

        }
        return "That is not a valid movie to return.";
    }

    public boolean searchAllMovie(String name) {
        return librarian.searchAllMovie(name);
    }

    public String checkoutMovie(String name) {
        if(searchMovie(name))
        {
            if(librarian.checkOutMovie(customer, name)!=null)
            {
                return "Thank you! Enjoy the movie";
            }

        }
        return "That movie is not available.";
    }

    public boolean searchMovie(String name) {
        return librarian.searchMovie(name);
    }

    public String getMovies() {
        return librarian.getMovies();
    }


}
